package com.project.controller;


import com.project.entity.SysStore;
import com.project.service.ISysStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wangsihan
 * @since 2021-10-08
 */
//@RestController
//@RequestMapping("/sys-store")
public class SysStoreController {

    @Autowired
    ISysStoreService sysStoreService;

    /**
     * 根据用户id，查询当前登录用户下所有的商铺
     *
     * @return 商铺集合
     */
    @GetMapping("findUserIdByStore/{userId}")
    public List<SysStore> findUserIdByStore(@PathVariable("userId") Integer userId) {
        return sysStoreService.findUserIdByStore(userId);
    }

    /**
     * 根据商铺id，更改商铺的状态
     *
     * @param StoreId 商铺id
     * @param status  商铺状态
     * @return 是否更改成功
     */
    @PostMapping("updateStoreStatus")
    public boolean updateStoreStatus(@RequestParam("StoreId") Integer StoreId, @RequestParam("status") String status) {
        return sysStoreService.updateStoreStatus(StoreId, status);
    }
}
